import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Java006 {
    public static void main(String[] args) {
        ArrayList<Integer> num1 = new ArrayList<>();
        Collections.addAll(num1,1,2,3);
        ArrayList<Integer> num2 = new ArrayList<>();
        Collections.addAll(num2,3,4,5,2);
        fun(num1,num2);

    }
    public static void fun(ArrayList<Integer> num1,ArrayList<Integer> num2){
        ArrayList<Integer> all= new ArrayList<>();

        List<Integer> str1 = num1.stream().collect(Collectors.toList());
        List<Integer> str2 = num2.stream().collect(Collectors.toList());

        List<Integer> list = Stream.concat(str1.stream(), str2.stream()).distinct().collect(Collectors.toList());
        System.out.println(list);//去重后

        List<Integer> list1 = Stream.concat(str1.stream(), str2.stream()).collect(Collectors.toList());

//        list1.removeAll(list);
        int n=list.size();
        ArrayList<Integer> flag = new ArrayList<>();
        ArrayList<Integer> copy = new ArrayList<>();copy.addAll(list1);
        while(true) {
            for (int i = 0; i < list1.size(); i++) {
                for (int j = 0; j < list.size(); j++) {
                    if (list1.get(i) == list.get(j)) {
                        list.remove(j);
                        list1.remove(i);
                    }
                }
            }
            if(list.size()==0){
                break;
            }
        }//找到相同的部分

        System.out.println(list1);
        List<Integer> listEnd = copy.stream().filter(s -> !list1.contains(s)).collect(Collectors.toList());
        System.out.println(listEnd);

    }
}
